﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Lian3.Models;

namespace Lian3.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            //一般存放不重要的数据
            // ViewBag贯穿控制器与视图的桥梁,不可以跨页面
            ViewBag.aaa = "sdafa";
            ViewData["bbb"] = "1212";
            return View();
        }

        public void About1()
        {
            //TempData只能读取一次数据，可以跨页面
            TempData["ccc"] = "cccc";
            Response.Redirect("~/Home/About2");
        }

        public ActionResult About2()
        {
            //TempData["ccc"] = "cccc";
            return View();
        }
        public ActionResult Contact()
        {
           // View可以传递类
            return View(new Student()
            {
                name = "张三",
                age=15,
                comment="盛世东方"
            });
        }

        public ActionResult Contact1()
        {
            // View（“传给指定的视图（默认为当前视图）”，类）
            //将student类传递到About2视图
            return View("About2", new Student()
            {
                name = "张三",
                age = 15,
                comment = "盛世东方"
            });
        }

        public ActionResult Contact3()
        {
            // View（“传给指定的视图（默认为当前视图）”,"指定的母版（默认为_Layout）"，类）
            //将student类传递到About2视图，母版为_Layout1
            return View("About2", "_Layout1", new Student()
            {
                name = "张三",
                age = 15,
                comment = "盛世东方"
            });
        }
    }
}